package editors.gui;
import graphics.system.Color;
import graphics.system.GLTools;
import tools.Point;
public class GuiLabel extends GuiObject {
	private String text;
	public boolean centertext;
	private Color bgcolor;
	public GuiLabel(Point pos, float width, String text) {
		super();
		this.rect = new Rect(pos.add(new Point(width / 2, -GuiSettings.LINEHEIGHT / 2)), width, GuiSettings.LINEHEIGHT);
		this.text = text;
		centertext = false;
		bgcolor = GuiSettings.LABEL_BG;
	}
	@Override
	public boolean isClicked() {
		return clicked;
	}
	@Override
	public boolean checkClick(Point mp) {
		this.clicked = rect.isIn(mp);
		return clicked;
	}
	@Override
	public void draw() {
		rect.draw(bgcolor);
		Point s = rect.getTopLeft();
		s.sAdd(new Point(2, -GuiSettings.FONTADJUST));
		if (!centertext)
			GLTools.drawText(s, text, GuiSettings.TEXT_COL, GuiSettings.FONTSIZE);
		else {
			s = rect.getCenter().add(new Point(0, -8));
			GLTools.drawText(s.add(new Point(-(10 * text.length()) / 2.0f, 0)), text, GuiSettings.TEXT_COL, GuiSettings.FONTSIZE);
		}
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public void setBackgroundColor(Color c) {
		this.bgcolor = c;
	}
}
